﻿@model WebChat.Models.ChannelIndexViewModel

<h2>Andre rom</h2>

<table>
    <tr>
        <th>
            Offentlig
        </th>
        <th>
            Id
        </th>
        <th>
            Navn
        </th>
        <th>
            Eier
        </th>
        <th>
            Dato
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.rooms) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.IsPublic)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Id)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => Model.getOwner(item.OwnerId).UserName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Date)
        </td>
        <td>
        @foreach (var user in Model.users)
        {
            if (user.Chatroom == item.Id && item.IsPublic == "No")
            {
                @Html.ActionLink("Åpne", "Room", new { id = item.Id })
            }
        }
        @if (item.IsPublic == "Yes")
        {
            @Html.ActionLink("Åpne", "Room", new { id = item.Id })
        }
        </td>
    </tr>
}

</table>
